import React, { useEffect, useState } from "react"; 
import { Space, Table, Tag } from 'antd';
import type { TableProps } from 'antd';
import axios from "axios";

const Index:React.FC=()=>{
    interface DataType {
  key: string;
  name: string;
  age: number;
  address: string; 
}
const [userList,setUserList]=useState([])
 
const columns: TableProps<DataType>['columns'] = [
  {
    title: '头像',
    dataIndex: 'info',
    key: 'info',
    render: (text) => <div><img src={text}/></div>,
  },
  {
    title: '用户名',
    dataIndex: 'username',
    key: 'username',
  },
  {
    title: '密码',
    dataIndex: 'passwrd',
    key: 'passwrd',
  } 
];

const data: DataType[] = userList;
    
    const render=()=>{
        axios.get('/api/v1/userlist').then((resp)=>{
            let {user}=resp.data
            console.log(user)
            setUserList(user)
        })
    }
    useEffect(()=>{
        render()
    },[])
    return <div><Table<DataType> columns={columns} dataSource={data} /></div>
}
export default Index